/**
  ******************************************************************************
  * @author     Chris
  * @since      2024/6/13 14:27
  *
  * @file       pd_timer_oc.h
  * @brief      Header file of TimerOC peripheral driver.
  *
  * @note       This file contains the TimerOC object declaration.
  *
  * @warning    None.
  ******************************************************************************
  * Change Logs:
  *   Date          Author       Notes
  *   2024/6/13     Chris        the first version
  *
  ******************************************************************************
  */

#ifndef JLC_SKY_TIMER_OC_H
#define JLC_SKY_TIMER_OC_H

#include "pd_timer.h"
#include "pd_timer_ch.h"
#include "drivers.h"

typedef struct TimerOCDef TimerOC;

/**
 * Timer Output Compare Unit
 */
struct TimerOCDef {
    Timer *timer;
    TimerCh *timerChannel;

    uint32_t OCMode;
    uint32_t OCState;
    uint32_t OCPolarity;
    uint32_t CompareValue;

    uint32_t OCNState;
    uint32_t OCNPolarity;
    uint32_t OCIdleState;
    uint32_t OCNIdleState;

    void (*init)(TimerOC *this);

    void (*setCCR)(TimerOC *this, uint32_t channel, uint32_t CompareValue);
};

extern const struct TimerOCClass {
    TimerOC *(*build)(Timer *timer, TimerCh *timerChannel, uint32_t CompareValue);
} TimerOCBuilder;

#endif //JLC_SKY_TIMER_OC_H
